<!--!
This file is a part of MediaDrop (https://www.mediadrop.video),
Copyright 2009-2018 MediaDrop contributors
For the exact contribution history, see the git revision log.
The source code contained in this file is licensed under the GPLv3 or
(at your option) any later version.
See LICENSE.txt in the main project directory, for more information.
-->
<form xmlns="http://www.w3.org/1999/xhtml"
      xmlns:py="http://genshi.edgewall.org/"
      xmlns:xi="http://www.w3.org/2001/XInclude"
      id="${id}"
      name="${name}"
      action="${action}"
      method="${method}"
      class="${css_class}"
      py:attrs="attrs"
      py:with="buttons = [f for f in children if getattr(f, 'type', None) in ('button', 'submit', 'reset', 'image')];">
	<div class="box-content">
		<div class="field-error" py:if="error and show_error" py:content="error" />
		<div py:if="hidden_fields">
			<div py:for="field in hidden_fields"
			     py:with="error=error_for(field)"
			     py:strip="True">
				<span py:replace="field.display(value_for(field), **args_for(field))" />
				<span py:if="show_children_errors and error and not field.show_error"
				      class="field-error" py:content="error" />
			</div>
		</div>
		<ul class="field-list" py:attrs="list_attrs">
			<li py:for="i, field in enumerate(fields)"
			    py:if="getattr(field, 'type', None) not in ['submit', 'reset', 'file']"
			    py:with="required=[None,' required'][int(field.is_required)];
			             error=error_for(field);
			             label_text = field.label_text and _(field.label_text) or None;
			             help_text = field.help_text and _(field.help_text) or None;
			             is_submit = getattr(field, 'type', None) == 'submit';"
			    id="${field.id}-container"
			    class="${i%2 and 'odd' or 'even'}${is_submit and ' submit' or None}"
			    py:attrs="args_for(field).get('container_attrs') or field.container_attrs">
				<div py:if="show_labels and label_text and not field.suppress_label"
				     id="${field.id}-label" class="form_label">
					<label for="${field.id}">${label_text}:</label>
				</div>
				<div class="form_field">
					${field.display(value_for(field), **args_for(field))}
				</div>
				<div py:if="field.name == 'description'" py:replace="xhtml_description('description')" />
				<span py:if="help_text" class="field-help" py:content="help_text" />
				<span py:if="show_children_errors and error and not field.show_error"
				      class="field-error" py:content="error" />
			</li>
		</ul>
		<span py:if="error and not error.error_dict" class="field-error" py:content="error" />
	</div>
	<div class="box-foot" py:if="buttons">
		<py:for each="field in buttons">
			<button py:replace="field.display()" />
		</py:for>
	</div>
</form>

